define(function (require, exports, module) {
  exports.loginMember = function () {
    $(document).keyup(function (event) {
      if (event.keyCode == 13) {
        $(".login").trigger('click');
      }
    })
    $(".login").click(function () {
      var _csrf = $("#_csrf").val();
      var admin_name = $(".form-group input[name=admin_name]").val();
      var admin_pwd = $(".form-group input[name=admin_pwd]").val();
      var url = $(this).attr("data-url");
      $.ajax({
        url: url,
        type: "POST",
        dataType: "json",
        data: {
          admin_name: admin_name,
          admin_pwd: admin_pwd,
          _csrf: _csrf
        },
        success: function (res) {
          if (res.code == 200) {
            if (res.admin_id == 1) {
              window.location.href = "/admin/member/index";
            }
          } else {
            alert(res.msg);
            window.location.reload();
          }
        }
      });
    });

  };
});
